package com.sinosoft.cloud.access.handler;

import com.sinosoft.cloud.access.codec.Decoder;
import com.sinosoft.cloud.access.codec.DecoderFactory;
import com.sinosoft.cloud.access.net.MessageObject;
import io.netty.channel.ChannelHandlerContext;

/**
 * Created by Administrator on 2017-12-29.
 */
public class DcoderHandler extends AbstractHandler {
    private DecoderFactory decoderFactory = DecoderFactory.getInstance();

    @Override
    MessageObject dealMessage(ChannelHandlerContext ctx, MessageObject messageObject) {
        Decoder decoder = decoderFactory.getDecoder(getAccessName());
        if (decoder == null) {
            return null;
        }
        String sendToBankMsg = decoder.encoder(messageObject.getSendToBankMsg());
        messageObject.setSendToBankMsg(sendToBankMsg);
        return messageObject;
    }
}
